/**
 * @program: clms-second
 * @description:
 * @author: mitu_echo
 * @create: 2021-07-26 21:12
 **/

package com.second.lease.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.second.common.pojo.R;
import com.second.lease.dao.CarCommentDao;
import com.second.lease.pojo.entity.CarComment;
import com.second.lease.pojo.vo.CarCommentVO;
import com.second.lease.service.CarCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class CarCommentServiceImpl implements CarCommentService {

    @Autowired
    private CarCommentDao carCommentDao;

    @Override
    public R showCarComment(Integer pageno,Integer pagesize) {

        PageHelper.startPage(pageno,pagesize);
        List<CarCommentVO> carCommentList = carCommentDao.showCarComent();
        PageInfo pageInfo = new PageInfo(carCommentList);
        return R.success().putListData(carCommentList).putObject(pageInfo);
    }

    @Override
    public R addCarComment(CarComment carComment) {

        carComment.setAddtime(LocalDateTime.now().toString());
        int i = carCommentDao.insert(carComment);
        if (i > 0) {
            return R.success();
        }
        return R.error();
    }
}
